//
//  UIBarButtonItem+Extension.m
//  01.SinaBlog
//
//  Created by Label on 12/13/15.
//  Copyright © 2015 Label. All rights reserved.
//

#import "UIBarButtonItem+Extension.h"

@implementation UIBarButtonItem (Extension)

+ (UIBarButtonItem *)itemWithTarget:(id)target Action:(SEL)action Image:(NSString *)image HighLightedImage:(NSString *)highLightedImage {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:highLightedImage] forState:UIControlStateHighlighted];
    [button setSize:button.currentBackgroundImage.size];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}

@end
